<template>
	<view>
		<view v-if="type == 'Db'">
			<uni-list v-for="(item,index) in data" :key="index">
				<uni-list-item :title="item.Name" note="" thumb="../../static/img/icon.png" thumbSize="lg"
					:rightText=" ''+item.allcount" clickable @click="toDetails(item)"></uni-list-item>
			</uni-list>
		</view>

		<view v-if="type == 'Yb'">
			<uni-list v-for="(item,index) in data" :key="index">
				<uni-list-item :title="item.WorkName" note="" thumb="../../static/img/icon.png" thumbSize="lg"
					:rightText=" ''+item.allcount" clickable @click="toDetails(item)"></uni-list-item>
			</uni-list>
		</view>

		<u-empty v-show="show" mode="list" style="padding-top: 30vh;" icon="/static/img/empty.png">
		</u-empty>

	</view>
</template>

<script>
	export default {
		data() {
			return {
				data: [],
				show: false,
				type: "Db",
				flag: ""
			}
		},
		onLoad(option) {

			this.type = option.pageData;

			if (this.type == 'Db') {
				this.getDataDb()
			} else if (this.type == 'Yb') {
				this.getDataYb()
			}

		},
		methods: {
			getDataDb() {
				this.$api.myAjaxFunc(Config.PlatformAPI + publicJs.Config.WorkFlowRun.GetMyTaskDBGroup, {
					SiteID: Common.Const.Site.SiteID,
					IsPC: "0"
				}).then((res) => {

					this.data = res.resultData;
					if (res.resultData.length == 0) {
						this.show = true;
					}

				})
			},
			getDataYb() {

				this.$api.myAjaxFunc(Config.PlatformAPI + publicJs.Config.WorkFlowRun.GetMyTaskYBGroup, {
					SiteID: Common.Const.Site.SiteID,
					IsPC: "0"
				}).then((res) => {

					this.data = res.resultData;
					if (res.resultData.length == 0) {
						this.show = true;
					}

				})
			},
			toDetails(param) {
 
				let fl = {
					flag: this.flag
				}

				let data = {
					...param,
					...fl
				}

				uni.navigateTo({
					url: "/pages/task/my" + this.type + "?pageData=" + this.$gl.uEncode(data)
				});

			}
		}
	}
</script>

<style lang="scss" scoped>
</style>
